package com.goodving.guli.bt.model;

import android.content.Context;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.goodving.guli.view.C4220a;

import org.json.JSONObject;

import cn.com.smartdevices.bracelet.config.C0886a;

/**
 * Created by john on 2015/12/4.
 */
@Table(name = "weightgoal")
public class WeightGoal extends Model {
    public static int GOAL_TYPE;
    private static final String TAG = WeightGoal.class.getSimpleName();
    public static int WEIGHTGOAL_NEED_DELETE;
    public static int WEIGHTGOAL_NEED_SYNC;
    public static int WEIGHTGOAL_SYNCED;
    @Column(name = "CurrentVal")
    public float currentVal;
   @Column(name = "DateTime")
    public long datetime;
   @Column(name = "FUID")
    public int fuid;
   @Column(name = "Goal")
    public float goal;
   @Column(name = "GoalType")
    public int goal_type;
   @Column(name = "Height")
    public int height;
   @Column(name = "Synced")
    public int synced;
   @Column(name = "UID")
    public long uid;

    public WeightGoal() {
        super();
    }

    public WeightGoal(WeightGoal weightGoal) {
        WEIGHTGOAL_NEED_DELETE = -1;
        WEIGHTGOAL_NEED_SYNC = 0;
        WEIGHTGOAL_SYNCED = 1;
        GOAL_TYPE = 1;
        currentVal = weightGoal.currentVal;
        goal_type = weightGoal.goal_type;
        height = weightGoal.height;
        synced = weightGoal.synced;
        uid = weightGoal.uid;
        datetime = weightGoal.datetime;
        fuid = weightGoal.fuid;
        goal = weightGoal.goal;
    }

    public WeightGoal(Context context, int i, float f, float f2, int i2) {
        this.uid = C0886a.m9071f(context).uid;
        this.fuid = i;
        this.goal_type = GOAL_TYPE;
        this.currentVal = f;
        this.goal = f2;
        this.datetime = System.currentTimeMillis() / 1000;
        this.height = i2;
        this.synced = WEIGHTGOAL_NEED_SYNC;
    }

    public WeightGoal(JSONObject jSONObject) {
        this.uid = jSONObject.optLong(C4220a.f20891n);
        this.goal_type = jSONObject.optInt("goal_type");
        this.currentVal = (float) jSONObject.optDouble("currentval");
        this.datetime = jSONObject.optLong("date_time");
        this.goal = (float) jSONObject.optDouble("goal");
        this.fuid = jSONObject.optInt("fuid");
        this.height = jSONObject.optInt("height");
        this.synced = WEIGHTGOAL_SYNCED;
    }
}
